package com.itheim.array;
/*
   键盘录入循环遍历
 */

import java.util.Scanner;

public class ArrayDemo10 {
    public static void main(String[] args) {
        //1.创建键盘录入对象
        Scanner sc = new Scanner(System.in);
        //2.定义长度为10的int类型的数组
        int[] arr=new int[10];
        //3.定义count1,count2,count3,count4
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        int count4 = 0;
        //4.建立for循环赋值
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"个数:");
            arr[i] = sc.nextInt();
            //5.for循环遍历数组并进行判断
            if (arr[i] == 1){
                count1++;
            }else if(arr[i]==2){
                count2++;
            }else if(arr[i]==3){
                count3++;
            }else{
                count4++;
            }
        }
        //6.打印统计结果
        System.out.println("1一共"+count1+"个");
        System.out.println("2一共"+count2+"个");
        System.out.println("3一共"+count3+"个");
        System.out.println("一共"+count4+"个");
    }
}
